home *** CD-ROM | disk | FTP | other *** search
/ Champak 122 / Vol 122.iso / games / cafe_wai.swf / scripts / frame_2 / DoAction.as
Text File  |  2011-01-06  |  54KB  |  1,432 lines

  1. function centreOnX(what)
  2. {
  3.    var _loc2_ = {x:bg[what]._x,y:0};
  4.    var _loc3_ = convertToLocal(_loc2_);
  5.    var _loc1_ = bg._x + stageCentre - _loc3_;
  6.    if(_loc1_ > bgLeftExtreme)
  7.    {
  8.       _loc1_ -= _loc1_ - bgLeftExtreme;
  9.    }
  10.    else if(_loc1_ < bgRightExtreme)
  11.    {
  12.       _loc1_ += bgRightExtreme - _loc1_;
  13.    }
  14.    bg._x = _loc1_;
  15. }
  16. function handleTable(which)
  17. {
  18.    bg.heroine.cateringChair = false;
  19.    if(bg["table" + which].state == "unclean1")
  20.    {
  21.       if(bg.heroine.carryFood1 == "" || bg.heroine.carryFood2 == "" || bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "")
  22.       {
  23.          if(bg.heroine.moveDirection == "left")
  24.          {
  25.             bg.heroine.gotoAndPlay("fromRight");
  26.          }
  27.          else if(bg.heroine.moveDirection == "right")
  28.          {
  29.             bg.heroine.gotoAndPlay("fromLeft");
  30.          }
  31.          bg.heroine.cateringChair = true;
  32.          var _loc4_ = true;
  33.          if(bg["table" + which].food1._visible && bg["table" + which].food1._currentframe == 5)
  34.          {
  35.             if(bg.heroine.carryFood1 == "")
  36.             {
  37.                bg.heroine.atTable = "1";
  38.                bg.heroine.carryFood1 = "plate";
  39.                bg["table" + which].food1._visible = false;
  40.                _root["tIcon" + which]["food" + bg["table" + which].chair1]._visible = false;
  41.                _root["tIcon" + which]["fIcon" + bg["table" + which].chair1]._visible = false;
  42.             }
  43.             else if(bg.heroine.carryFood2 == "")
  44.             {
  45.                bg.heroine.atTable = "1";
  46.                bg.heroine.carryFood2 = "plate";
  47.                bg["table" + which].food1._visible = false;
  48.                _root["tIcon" + which]["food" + bg["table" + which].chair1]._visible = false;
  49.                _root["tIcon" + which]["fIcon" + bg["table" + which].chair1]._visible = false;
  50.             }
  51.             else
  52.             {
  53.                _loc4_ = false;
  54.             }
  55.          }
  56.          if(bg["table" + which].drink1._visible && bg["table" + which].drink1._currentframe > 4)
  57.          {
  58.             if(bg.heroine.carryDrink1 == "")
  59.             {
  60.                bg.heroine.atTable = "1";
  61.                switch(bg["table" + which].drink1._currentframe)
  62.                {
  63.                   case 5:
  64.                      bg.heroine.carryDrink1 = "colaC";
  65.                      break;
  66.                   case 6:
  67.                      bg.heroine.carryDrink1 = "orangeC";
  68.                      break;
  69.                   case 7:
  70.                      bg.heroine.carryDrink1 = "limeC";
  71.                      break;
  72.                   case 8:
  73.                      bg.heroine.carryDrink1 = "coffeeC";
  74.                }
  75.                bg["table" + which].drink1._visible = false;
  76.                _root["tIcon" + which]["drink" + bg["table" + which].chair1]._visible = false;
  77.                _root["tIcon" + which]["dIcon" + bg["table" + which].chair1]._visible = false;
  78.             }
  79.             else if(bg.heroine.carryDrink2 == "")
  80.             {
  81.                bg.heroine.atTable = "1";
  82.                switch(bg["table" + which].drink1._currentframe)
  83.                {
  84.                   case 5:
  85.                      bg.heroine.carryDrink2 = "colaC";
  86.                      break;
  87.                   case 6:
  88.                      bg.heroine.carryDrink2 = "orangeC";
  89.                      break;
  90.                   case 7:
  91.                      bg.heroine.carryDrink2 = "limeC";
  92.                      break;
  93.                   case 8:
  94.                      bg.heroine.carryDrink2 = "coffeeC";
  95.                }
  96.                bg["table" + which].drink1._visible = false;
  97.                _root["tIcon" + which]["drink" + bg["table" + which].chair1]._visible = false;
  98.                _root["tIcon" + which]["dIcon" + bg["table" + which].chair1]._visible = false;
  99.             }
  100.             else
  101.             {
  102.                _loc4_ = false;
  103.             }
  104.          }
  105.          if(_loc4_)
  106.          {
  107.             if(bg["table" + which].firstChair == "" && bg["table" + which].secondChair == "")
  108.             {
  109.                _root["tIcon" + which].gotoAndStop("init");
  110.                _root["tIcon" + which].num.gotoAndStop(which);
  111.             }
  112.             if(bg["table" + which].food2._visible && bg["table" + which].food2._currentframe == 5 || bg["table" + which].drink2._visible && bg["table" + which].drink2._currentframe > 4)
  113.             {
  114.                bg["table" + which].state = "unclean2";
  115.             }
  116.             else
  117.             {
  118.                bg["table" + which].state = "cleanBoth";
  119.             }
  120.          }
  121.          popup.gotoAndPlay("plate");
  122.       }
  123.    }
  124.    if(bg["table" + which].state == "unclean2")
  125.    {
  126.       if(bg.heroine.carryFood1 == "" || bg.heroine.carryFood2 == "" || bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "")
  127.       {
  128.          if(!bg.heroine.cateringChair)
  129.          {
  130.             if(bg.heroine.moveDirection == "left")
  131.             {
  132.                bg.heroine.gotoAndPlay("fromRight");
  133.             }
  134.             else if(bg.heroine.moveDirection == "right")
  135.             {
  136.                bg.heroine.gotoAndPlay("fromLeft");
  137.             }
  138.          }
  139.          _loc4_ = true;
  140.          if(bg["table" + which].food2._visible && bg["table" + which].food2._currentframe == 5)
  141.          {
  142.             if(bg.heroine.carryFood1 == "")
  143.             {
  144.                if(!bg.heroine.cateringChair)
  145.                {
  146.                   bg.heroine.atTable = "2";
  147.                }
  148.                bg.heroine.carryFood1 = "plate";
  149.                bg["table" + which].food2._visible = false;
  150.                _root["tIcon" + which]["food" + bg["table" + which].chair2]._visible = false;
  151.                _root["tIcon" + which]["fIcon" + bg["table" + which].chair2]._visible = false;
  152.             }
  153.             else if(bg.heroine.carryFood2 == "")
  154.             {
  155.                if(!bg.heroine.cateringChair)
  156.                {
  157.                   bg.heroine.atTable = "2";
  158.                }
  159.                bg.heroine.carryFood2 = "plate";
  160.                bg["table" + which].food2._visible = false;
  161.                _root["tIcon" + which]["food" + bg["table" + which].chair2]._visible = false;
  162.                _root["tIcon" + which]["fIcon" + bg["table" + which].chair2]._visible = false;
  163.             }
  164.             else
  165.             {
  166.                _loc4_ = false;
  167.             }
  168.          }
  169.          if(bg["table" + which].drink2._visible && bg["table" + which].drink2._currentframe > 4)
  170.          {
  171.             if(bg.heroine.carryDrink1 == "")
  172.             {
  173.                if(!bg.heroine.cateringChair)
  174.                {
  175.                   bg.heroine.atTable = "2";
  176.                }
  177.                switch(bg["table" + which].drink2._currentframe)
  178.                {
  179.                   case 5:
  180.                      bg.heroine.carryDrink1 = "colaC";
  181.                      break;
  182.                   case 6:
  183.                      bg.heroine.carryDrink1 = "orangeC";
  184.                      break;
  185.                   case 7:
  186.                      bg.heroine.carryDrink1 = "limeC";
  187.                      break;
  188.                   case 8:
  189.                      bg.heroine.carryDrink1 = "coffeeC";
  190.                }
  191.                bg["table" + which].drink2._visible = false;
  192.                _root["tIcon" + which]["drink" + bg["table" + which].chair2]._visible = false;
  193.                _root["tIcon" + which]["dIcon" + bg["table" + which].chair2]._visible = false;
  194.             }
  195.             else if(bg.heroine.carryDrink2 == "")
  196.             {
  197.                if(!bg.heroine.cateringChair)
  198.                {
  199.                   bg.heroine.atTable = "2";
  200.                }
  201.                switch(bg["table" + which].drink2._currentframe)
  202.                {
  203.                   case 5:
  204.                      bg.heroine.carryDrink2 = "colaC";
  205.                      break;
  206.                   case 6:
  207.                      bg.heroine.carryDrink2 = "orangeC";
  208.                      break;
  209.                   case 7:
  210.                      bg.heroine.carryDrink2 = "limeC";
  211.                      break;
  212.                   case 8:
  213.                      bg.heroine.carryDrink2 = "coffeeC";
  214.                }
  215.                bg["table" + which].drink2._visible = false;
  216.                _root["tIcon" + which]["drink" + bg["table" + which].chair2]._visible = false;
  217.                _root["tIcon" + which]["dIcon" + bg["table" + which].chair2]._visible = false;
  218.             }
  219.             else
  220.             {
  221.                _loc4_ = false;
  222.             }
  223.          }
  224.          if(_loc4_)
  225.          {
  226.             if(bg["table" + which].firstChair == "" && bg["table" + which].secondChair == "")
  227.             {
  228.                _root["tIcon" + which].gotoAndStop("init");
  229.                _root["tIcon" + which].num.gotoAndStop(which);
  230.             }
  231.             if(bg["table" + which].food1._visible && bg["table" + which].food1._currentframe == 5 || bg["table" + which].drink1._visible && bg["table" + which].drink1._currentframe > 4)
  232.             {
  233.                bg["table" + which].state = "unclean1";
  234.             }
  235.             else
  236.             {
  237.                bg["table" + which].state = "cleanBoth";
  238.             }
  239.          }
  240.          bg.heroine.cateringChair = true;
  241.          popup.gotoAndPlay("plate");
  242.       }
  243.    }
  244.    if(!bg.heroine.cateringChair)
  245.    {
  246.       if(bg["table" + which].firstChair != "" && bg["table" + which].state != "unclean1")
  247.       {
  248.          if(bg["table" + which].firstChair.state == "order")
  249.          {
  250.             bg.heroine.cateringChair = true;
  251.             if(bg.heroine.moveDirection == "left")
  252.             {
  253.                bg.heroine.gotoAndPlay("takeOrderLeft");
  254.             }
  255.             else if(bg.heroine.moveDirection == "right")
  256.             {
  257.                bg.heroine.gotoAndPlay("takeOrderRight");
  258.             }
  259.             occuppiedChairs[bg["table" + which].firstChair.chairIndex] = customerWait;
  260.             if(bg["table" + which].secondChair == "")
  261.             {
  262.                _root["tIcon" + which].gotoAndStop("order");
  263.                _root["tIcon" + which].table.gotoAndStop(which);
  264.                _root["tIcon" + which].icon2._visible = false;
  265.                _root["tIcon" + which].fIcon2._visible = false;
  266.                _root["tIcon" + which].dIcon2._visible = false;
  267.                _root["tIcon" + which].food2._visible = false;
  268.                _root["tIcon" + which].drink2._visible = false;
  269.             }
  270.             else if(bg["table" + which].secondChair.state == "order")
  271.             {
  272.                _root["tIcon" + which].gotoAndStop("order");
  273.                _root["tIcon" + which].table.gotoAndStop(which);
  274.                _root["tIcon" + which].icon2._visible = true;
  275.                _root["tIcon" + which].fIcon2._visible = false;
  276.                _root["tIcon" + which].dIcon2._visible = false;
  277.                _root["tIcon" + which].food2._visible = false;
  278.                _root["tIcon" + which].drink2._visible = false;
  279.             }
  280.             bg["table" + which].chair1 = "1";
  281.             _root["tIcon" + which].icon1._visible = false;
  282.             _root["tIcon" + which].food1._visible = true;
  283.             _root["tIcon" + which].drink1._visible = true;
  284.             _root["tIcon" + which].fIcon1._visible = true;
  285.             _root["tIcon" + which].dIcon1._visible = true;
  286.             _root["tIcon" + which].food1.gotoAndStop(bg["table" + which].firstChair.food);
  287.             _root["tIcon" + which].fIcon1.gotoAndStop(bg["table" + which].firstChair.food);
  288.             _root["tIcon" + which].drink1.gotoAndStop(bg["table" + which].firstChair.drink);
  289.             _root["tIcon" + which].dIcon1.gotoAndStop(bg["table" + which].firstChair.drink);
  290.             bg.heroine.drink1 = bg["table" + which].firstChair.drink;
  291.             bg.heroine.food1 = bg["table" + which].firstChair.food;
  292.             bg["table" + which].firstChair.state = "both";
  293.             if(bg["table" + which].firstChair.moveDirection == "left")
  294.             {
  295.                bg["table" + which].firstChair.gotoAndPlay("relaxLeft");
  296.             }
  297.             else if(bg["table" + which].firstChair.moveDirection == "right")
  298.             {
  299.                bg["table" + which].firstChair.gotoAndPlay("relaxRight");
  300.             }
  301.          }
  302.          else
  303.          {
  304.             var _loc3_ = false;
  305.             if(bg["table" + which].firstChair.food == bg.heroine.carryFood1 && bg["table" + which].firstChair.state != "done")
  306.             {
  307.                _loc3_ = true;
  308.                _root["tIcon" + which].food1.gotoAndStop(Number(_root["tIcon" + which].food1._currentframe) + 4);
  309.                arrangeFood(bg.heroine.carryFood1,which,bg["table" + which].firstChair);
  310.                bg["table" + which].firstChair.gotFood = true;
  311.                if(bg["table" + which].firstChair.gotDrink)
  312.                {
  313.                   bg["table" + which].firstChair.state = "done";
  314.                }
  315.                bg.heroine.carryFood1 = "";
  316.             }
  317.             else if(bg["table" + which].firstChair.food == bg.heroine.carryFood2 && bg["table" + which].firstChair.state != "done")
  318.             {
  319.                _loc3_ = true;
  320.                _root["tIcon" + which].food1.gotoAndStop(Number(_root["tIcon" + which].food1._currentframe) + 4);
  321.                arrangeFood(bg.heroine.carryFood2,which,bg["table" + which].firstChair);
  322.                bg["table" + which].firstChair.gotFood = true;
  323.                if(bg["table" + which].firstChair.gotDrink)
  324.                {
  325.                   bg["table" + which].firstChair.state = "done";
  326.                }
  327.                bg.heroine.carryFood2 = "";
  328.             }
  329.             if(bg["table" + which].firstChair.drink == bg.heroine.carryDrink1 && bg["table" + which].firstChair.state != "done")
  330.             {
  331.                _loc3_ = true;
  332.                _root["tIcon" + which].drink1.gotoAndStop(Number(_root["tIcon" + which].drink1._currentframe) + 4);
  333.                arrangeDrink(bg.heroine.carryDrink1,which,bg["table" + which].firstChair);
  334.                bg["table" + which].firstChair.gotDrink = true;
  335.                if(bg["table" + which].firstChair.gotFood)
  336.                {
  337.                   bg["table" + which].firstChair.state = "done";
  338.                }
  339.                bg.heroine.carryDrink1 = "";
  340.             }
  341.             else if(bg["table" + which].firstChair.drink == bg.heroine.carryDrink2 && bg["table" + which].firstChair.state != "done")
  342.             {
  343.                _loc3_ = true;
  344.                _root["tIcon" + which].drink1.gotoAndStop(Number(_root["tIcon" + which].drink1._currentframe) + 4);
  345.                arrangeDrink(bg.heroine.carryDrink2,which,bg["table" + which].firstChair);
  346.                bg["table" + which].firstChair.gotDrink = true;
  347.                if(bg["table" + which].firstChair.gotFood)
  348.                {
  349.                   bg["table" + which].firstChair.state = "done";
  350.                }
  351.                bg.heroine.carryDrink2 = "";
  352.             }
  353.             if(_loc3_)
  354.             {
  355.                bg.heroine.cateringChair = true;
  356.                bg["table" + which].firstChair.eating = true;
  357.                occuppiedChairs[bg["table" + which].firstChair.chairIndex] = customerWait;
  358.                if(bg["table" + which].firstChair.moveDirection == "left")
  359.                {
  360.                   if(bg["table" + which].firstChair.gotFood == true)
  361.                   {
  362.                      bg["table" + which].firstChair.gotoAndPlay("eatingLeft");
  363.                   }
  364.                   else if(bg["table" + which].firstChair.gotDrink == true)
  365.                   {
  366.                      bg["table" + which].firstChair.gotoAndPlay("drinkLeft");
  367.                   }
  368.                   bg.heroine.gotoAndPlay("giveFoodRight");
  369.                }
  370.                else if(bg["table" + which].firstChair.moveDirection == "right")
  371.                {
  372.                   if(bg["table" + which].firstChair.gotFood == true)
  373.                   {
  374.                      bg["table" + which].firstChair.gotoAndPlay("eatingRight");
  375.                   }
  376.                   else if(bg["table" + which].firstChair.gotDrink == true)
  377.                   {
  378.                      bg["table" + which].firstChair.gotoAndPlay("drinkRight");
  379.                   }
  380.                   bg.heroine.gotoAndPlay("giveFoodLeft");
  381.                }
  382.                popup.gotoAndPlay("plate");
  383.             }
  384.          }
  385.       }
  386.       if(bg["table" + which].secondChair != "" && bg["table" + which].state != "unclean2")
  387.       {
  388.          if(bg["table" + which].secondChair.state == "order")
  389.          {
  390.             if(!bg.heroine.cateringChair)
  391.             {
  392.                if(bg.heroine.moveDirection == "left")
  393.                {
  394.                   bg.heroine.gotoAndPlay("takeOrderLeft");
  395.                }
  396.                else if(bg.heroine.moveDirection == "right")
  397.                {
  398.                   bg.heroine.gotoAndPlay("takeOrderRight");
  399.                }
  400.             }
  401.             occuppiedChairs[bg["table" + which].secondChair.chairIndex] = customerWait;
  402.             if(bg["table" + which].firstChair == "")
  403.             {
  404.                _root["tIcon" + which].gotoAndStop("order");
  405.                _root["tIcon" + which].table.gotoAndStop(which);
  406.                _root["tIcon" + which].fIcon1._visible = false;
  407.                _root["tIcon" + which].dIcon1._visible = false;
  408.                _root["tIcon" + which].food1._visible = false;
  409.                _root["tIcon" + which].drink1._visible = false;
  410.             }
  411.             else if(bg["table" + which].firstChair.state == "order")
  412.             {
  413.                _root["tIcon" + which].gotoAndStop("order");
  414.                _root["tIcon" + which].icon1._visible = true;
  415.                _root["tIcon" + which].table.gotoAndStop(which);
  416.                _root["tIcon" + which].fIcon1._visible = false;
  417.                _root["tIcon" + which].dIcon1._visible = false;
  418.                _root["tIcon" + which].food1._visible = false;
  419.                _root["tIcon" + which].drink1._visible = false;
  420.             }
  421.             _root["tIcon" + which].icon2._visible = false;
  422.             _root["tIcon" + which].fIcon2._visible = true;
  423.             _root["tIcon" + which].dIcon2._visible = true;
  424.             _root["tIcon" + which].food2._visible = true;
  425.             _root["tIcon" + which].drink2._visible = true;
  426.             _root["tIcon" + which].food2.gotoAndStop(bg["table" + which].secondChair.food);
  427.             _root["tIcon" + which].fIcon2.gotoAndStop(bg["table" + which].secondChair.food);
  428.             _root["tIcon" + which].drink2.gotoAndStop(bg["table" + which].secondChair.drink);
  429.             _root["tIcon" + which].dIcon2.gotoAndStop(bg["table" + which].secondChair.drink);
  430.             bg.heroine.drink2 = bg["table" + which].secondChair.drink;
  431.             bg.heroine.food2 = bg["table" + which].secondChair.food;
  432.             bg["table" + which].secondChair.state = "both";
  433.             if(bg["table" + which].secondChair.moveDirection == "left")
  434.             {
  435.                bg["table" + which].secondChair.gotoAndPlay("relaxLeft");
  436.             }
  437.             else if(bg["table" + which].secondChair.moveDirection == "right")
  438.             {
  439.                bg["table" + which].secondChair.gotoAndPlay("relaxRight");
  440.             }
  441.             bg.heroine.cateringChair = true;
  442.          }
  443.          else
  444.          {
  445.             _loc3_ = false;
  446.             if(bg["table" + which].secondChair.food == bg.heroine.carryFood1 && bg["table" + which].secondChair.state != "done")
  447.             {
  448.                _loc3_ = true;
  449.                _root["tIcon" + which].food2.gotoAndStop(Number(_root["tIcon" + which].food2._currentframe) + 4);
  450.                arrangeFood(bg.heroine.carryFood1,which,bg["table" + which].secondChair);
  451.                bg["table" + which].secondChair.gotFood = true;
  452.                if(bg["table" + which].secondChair.gotDrink)
  453.                {
  454.                   bg["table" + which].secondChair.state = "done";
  455.                }
  456.                bg.heroine.carryFood1 = "";
  457.             }
  458.             else if(bg["table" + which].secondChair.food == bg.heroine.carryFood2 && bg["table" + which].secondChair.state != "done")
  459.             {
  460.                _loc3_ = true;
  461.                _root["tIcon" + which].food2.gotoAndStop(Number(_root["tIcon" + which].food2._currentframe) + 4);
  462.                arrangeFood(bg.heroine.carryFood2,which,bg["table" + which].secondChair);
  463.                bg["table" + which].secondChair.gotFood = true;
  464.                if(bg["table" + which].secondChair.gotDrink)
  465.                {
  466.                   bg["table" + which].secondChair.state = "done";
  467.                }
  468.                bg.heroine.carryFood2 = "";
  469.             }
  470.             if(bg["table" + which].secondChair.drink == bg.heroine.carryDrink1 && bg["table" + which].secondChair.state != "done")
  471.             {
  472.                _loc3_ = true;
  473.                _root["tIcon" + which].drink2.gotoAndStop(Number(_root["tIcon" + which].drink2._currentframe) + 4);
  474.                arrangeDrink(bg.heroine.carryDrink1,which,bg["table" + which].secondChair);
  475.                bg["table" + which].secondChair.gotDrink = true;
  476.                if(bg["table" + which].secondChair.gotFood)
  477.                {
  478.                   bg["table" + which].secondChair.state = "done";
  479.                }
  480.                bg.heroine.carryDrink1 = "";
  481.             }
  482.             else if(bg["table" + which].secondChair.drink == bg.heroine.carryDrink2 && bg["table" + which].secondChair.state != "done")
  483.             {
  484.                _loc3_ = true;
  485.                _root["tIcon" + which].drink2.gotoAndStop(Number(_root["tIcon" + which].drink2._currentframe) + 4);
  486.                arrangeDrink(bg.heroine.carryDrink2,which,bg["table" + which].secondChair);
  487.                bg["table" + which].secondChair.gotDrink = true;
  488.                if(bg["table" + which].secondChair.gotFood)
  489.                {
  490.                   bg["table" + which].secondChair.state = "done";
  491.                }
  492.                bg.heroine.carryDrink2 = "";
  493.             }
  494.             if(_loc3_)
  495.             {
  496.                bg["table" + which].secondChair.eating = true;
  497.                occuppiedChairs[bg["table" + which].secondChair.chairIndex] = customerWait;
  498.                if(bg["table" + which].secondChair.moveDirection == "left")
  499.                {
  500.                   if(bg["table" + which].secondChair.gotFood == true)
  501.                   {
  502.                      bg["table" + which].secondChair.gotoAndPlay("eatingLeft");
  503.                   }
  504.                   else if(bg["table" + which].secondChair.gotDrink == true)
  505.                   {
  506.                      bg["table" + which].secondChair.gotoAndPlay("drinkLeft");
  507.                   }
  508.                   if(!bg.heroine.cateringChair)
  509.                   {
  510.                      bg.heroine.gotoAndPlay("giveFoodRight");
  511.                   }
  512.                }
  513.                else if(bg["table" + which].secondChair.moveDirection == "right")
  514.                {
  515.                   if(bg["table" + which].secondChair.gotFood == true)
  516.                   {
  517.                      bg["table" + which].secondChair.gotoAndPlay("eatingRight");
  518.                   }
  519.                   else if(bg["table" + which].secondChair.gotDrink == true)
  520.                   {
  521.                      bg["table" + which].secondChair.gotoAndPlay("drinkRight");
  522.                   }
  523.                   if(!bg.heroine.cateringChair)
  524.                   {
  525.                      bg.heroine.gotoAndPlay("giveFoodLeft");
  526.                   }
  527.                }
  528.                bg.heroine.cateringChair = true;
  529.                popup.gotoAndPlay("plate");
  530.             }
  531.          }
  532.       }
  533.    }
  534.    if(!bg.heroine.cateringChair)
  535.    {
  536.       if(bg.heroine.moveDirection == "left")
  537.       {
  538.          bg.heroine.gotoAndPlay("toLeft");
  539.       }
  540.       else if(bg.heroine.moveDirection == "right")
  541.       {
  542.          bg.heroine.gotoAndPlay("toRight");
  543.       }
  544.    }
  545.    bg.heroine.destination = "";
  546. }
  547. function arrangeFood(food, which, cust)
  548. {
  549.    var _loc1_ = cust.chair % 2;
  550.    if(_loc1_ == 0)
  551.    {
  552.       _loc1_ = 2;
  553.    }
  554.    bg["table" + which]["food" + _loc1_]._visible = true;
  555.    bg["table" + which]["food" + _loc1_].gotoAndStop(food);
  556.    bg["table" + which]["f" + _loc1_ + "Done"] = true;
  557. }
  558. function arrangeDrink(drink, which, cust)
  559. {
  560.    var _loc1_ = cust.chair % 2;
  561.    if(_loc1_ == 0)
  562.    {
  563.       _loc1_ = 2;
  564.    }
  565.    bg["table" + which]["drink" + _loc1_]._visible = true;
  566.    bg["table" + which]["drink" + _loc1_].gotoAndStop(drink);
  567.    bg["table" + which]["d" + _loc1_ + "Done"] = true;
  568. }
  569. function handleTurn()
  570. {
  571.    if(bg.heroine.moveDirection == "left")
  572.    {
  573.       bg.heroine.gotoAndPlay("fromRight");
  574.    }
  575.    else if(bg.heroine.moveDirection == "right")
  576.    {
  577.       bg.heroine.gotoAndPlay("fromLeft");
  578.    }
  579. }
  580. function handleDishes()
  581. {
  582.    if(currentWastePlates < maxWastePlates && (bg.heroine.carryFood2 == "plate" || bg.heroine.carryFood1 == "plate"))
  583.    {
  584.       bg.dishes.active = true;
  585.       if(bg.heroine.carryFood1 == "plate")
  586.       {
  587.          currentWastePlates++;
  588.          bg.heroine.carryFood1 = "";
  589.       }
  590.       if(bg.heroine.carryFood2 == "plate")
  591.       {
  592.          currentWastePlates++;
  593.          bg.heroine.carryFood2 = "";
  594.       }
  595.       bg.heroine.gotoAndPlay("placeDish");
  596.       popup.gotoAndPlay("plate");
  597.    }
  598.    else
  599.    {
  600.       bg.heroine.active = false;
  601.       if(bg.heroine.moveDirection == "left")
  602.       {
  603.          bg.heroine.gotoAndStop("initLeft");
  604.       }
  605.       else if(bg.heroine.moveDirection == "right")
  606.       {
  607.          bg.heroine.gotoAndStop("initRight");
  608.       }
  609.    }
  610.    bg.heroine.destination = "";
  611. }
  612. function assignDrink(drink)
  613. {
  614.    bg.drinkMaker.active = true;
  615.    maxDrinks--;
  616.    if(bg.heroine.carryDrink1 == "")
  617.    {
  618.       bg.heroine.carryDrink1 = drink;
  619.       bg.heroine.drink1 = "";
  620.    }
  621.    else if(bg.heroine.carryDrink2 == "")
  622.    {
  623.       bg.heroine.carryDrink2 = drink;
  624.       bg.heroine.drink2 = "";
  625.    }
  626.    popup.gotoAndPlay("plate");
  627.    bg.heroine.gotoAndPlay("getDrinks");
  628. }
  629. function assignWorker(work)
  630. {
  631.    bg.worker.active = true;
  632.    bg.heroine.gotoAndPlay("getFood");
  633.    switch(work)
  634.    {
  635.       case "coffee":
  636.          binFrame = bg.worker.bin._currentframe;
  637.          bg.coffeeCups.active = true;
  638.          bg.worker.gotoAndPlay("coffeeRefill");
  639.          break;
  640.       case "bin":
  641.          binFrame = bg.worker.bin._currentframe;
  642.          bg.worker.gotoAndPlay("recycle");
  643.          break;
  644.       case "drinks":
  645.          binFrame = bg.worker.bin._currentframe;
  646.          bg.drinkMaker.active = true;
  647.          bg.worker.gotoAndPlay("drinksRefill");
  648.          break;
  649.       case "wash":
  650.          bg.dishes.active = true;
  651.          bg.dishes.gotoAndPlay("worker");
  652.    }
  653.    popup.gotoAndPlay("plate");
  654. }
  655. function assignFood(pfood)
  656. {
  657.    bg.kitchen.active = true;
  658.    activity.active = true;
  659.    activity.gotoAndStop(pfood);
  660.    activity.clip.gotoAndPlay(1);
  661.    bg.kitchen.foodReady = false;
  662.    bg.kitchen.order = pfood;
  663.    kitchenTimer = 100;
  664.    bg.kitchen.gotoAndPlay("chef");
  665.    bg.heroine.gotoAndPlay("order");
  666.    popup.gotoAndPlay("plate");
  667. }
  668. function handleHeroine()
  669. {
  670.    switch(bg.heroine.destination)
  671.    {
  672.       case "coffeePos":
  673.          if((bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "") && bg.coffeeCups._currentframe <= maxCoffeeGlasses)
  674.          {
  675.             if(bg.heroine.carryDrink1 == "")
  676.             {
  677.                bg.heroine.carryDrink1 = "coffee";
  678.                bg.heroine.drink1 = "";
  679.             }
  680.             else if(bg.heroine.carryDrink2 == "")
  681.             {
  682.                bg.heroine.carryDrink2 = "coffee";
  683.                bg.heroine.drink2 = "";
  684.             }
  685.             bg.coffeeCups.active = true;
  686.             bg.coffeeCups.gotoAndStop(bg.coffeeCups._currentframe + 1);
  687.             popup.gotoAndPlay("plate");
  688.             bg.heroine.gotoAndPlay("getCoffee");
  689.          }
  690.          else
  691.          {
  692.             bg.heroine.active = false;
  693.             if(bg.heroine.moveDirection == "left")
  694.             {
  695.                bg.heroine.gotoAndPlay("toLeft");
  696.             }
  697.             else if(bg.heroine.moveDirection == "right")
  698.             {
  699.                bg.heroine.gotoAndPlay("toRight");
  700.             }
  701.          }
  702.          break;
  703.       case "drinkPos":
  704.          if((bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "") && maxDrinks > 0)
  705.          {
  706.             popup.gotoAndStop("drinkMaker");
  707.          }
  708.          else
  709.          {
  710.             bg.heroine.active = false;
  711.             if(bg.heroine.moveDirection == "left")
  712.             {
  713.                bg.heroine.gotoAndPlay("toLeft");
  714.             }
  715.             else if(bg.heroine.moveDirection == "right")
  716.             {
  717.                bg.heroine.gotoAndPlay("toRight");
  718.             }
  719.          }
  720.          break;
  721.       case "kitchen":
  722.          if(bg.kitchen.order == "")
  723.          {
  724.             popup.gotoAndStop("kitchen");
  725.          }
  726.          else if(bg.kitchen.delivered && (bg.heroine.carryFood1 == "" || bg.heroine.carryFood2 == ""))
  727.          {
  728.             bg.heroine.gotoAndPlay("getFood");
  729.             if(bg.heroine.carryFood1 == "")
  730.             {
  731.                bg.heroine.carryFood1 = bg.kitchen.order;
  732.             }
  733.             else if(bg.heroine.carryFood2 == "")
  734.             {
  735.                bg.heroine.carryFood2 = bg.kitchen.order;
  736.             }
  737.             bg.kitchen.delivered = false;
  738.             bg.kitchen.order = "";
  739.             bg.kitchen.food._visible = false;
  740.             popup.gotoAndPlay("plate");
  741.          }
  742.          else
  743.          {
  744.             bg.heroine.active = false;
  745.             if(bg.heroine.moveDirection == "left")
  746.             {
  747.                bg.heroine.gotoAndPlay("toLeft");
  748.             }
  749.             else if(bg.heroine.moveDirection == "right")
  750.             {
  751.                bg.heroine.gotoAndPlay("toRight");
  752.             }
  753.          }
  754.          break;
  755.       case "worker":
  756.          if(!bg.worker.active)
  757.          {
  758.             popup.gotoAndStop("worker");
  759.          }
  760.          else
  761.          {
  762.             bg.heroine.active = false;
  763.             if(bg.heroine.moveDirection == "left")
  764.             {
  765.                bg.heroine.gotoAndPlay("toLeft");
  766.             }
  767.             else if(bg.heroine.moveDirection == "right")
  768.             {
  769.                bg.heroine.gotoAndPlay("toRight");
  770.             }
  771.          }
  772.          break;
  773.       case "recycle":
  774.          if(currentWasteGlasses < maxWasteGlasses && (bg.heroine.carryDrink1.charAt(bg.heroine.carryDrink1.length - 1) == "C" || bg.heroine.carryDrink2.charAt(bg.heroine.carryDrink2.length - 1) == "C"))
  775.          {
  776.             if(bg.heroine.carryDrink1.charAt(bg.heroine.carryDrink1.length - 1) == "C")
  777.             {
  778.                currentWasteGlasses++;
  779.                bg.heroine.carryDrink1 = "";
  780.             }
  781.             if(bg.heroine.carryDrink2.charAt(bg.heroine.carryDrink2.length - 1) == "C")
  782.             {
  783.                currentWasteGlasses++;
  784.                bg.heroine.carryDrink2 = "";
  785.             }
  786.             if(currentWasteGlasses >= maxWasteGlasses - 4)
  787.             {
  788.                bg.worker.bin.gotoAndStop(bg.worker.bin._currentframe + 1);
  789.             }
  790.             bg.heroine.gotoAndPlay("recycle");
  791.             popup.gotoAndPlay("plate");
  792.          }
  793.          else
  794.          {
  795.             bg.heroine.active = false;
  796.             if(bg.heroine.moveDirection == "left")
  797.             {
  798.                bg.heroine.gotoAndPlay("toLeft");
  799.             }
  800.             else if(bg.heroine.moveDirection == "right")
  801.             {
  802.                bg.heroine.gotoAndPlay("toRight");
  803.             }
  804.          }
  805.    }
  806.    bg.heroine.destination = "";
  807. }
  808. function cancelActivity()
  809. {
  810.    bg.heroine.active = false;
  811.    if(bg.heroine.moveDirection == "left")
  812.    {
  813.       bg.heroine.gotoAndPlay("toLeft");
  814.    }
  815.    else if(bg.heroine.moveDirection == "right")
  816.    {
  817.       bg.heroine.gotoAndPlay("toRight");
  818.    }
  819.    popup.gotoAndPlay("plate");
  820. }
  821. function initGame()
  822. {
  823.    binFrame = 1;
  824.    maxDrinks = 10;
  825.    help_Mc._visible = false;
  826.    score = 0;
  827.    customerReleaseDelay = 600;
  828.    currentWastePlates = 0;
  829.    currentWasteGlasses = 0;
  830.    occuppiedChairs = new Array(0,0,0,0,0,0,0,0,0,0);
  831.    customerChairArray = new Array("","","","","","","","","","");
  832.    availableCustomers = new Array(1,2,3,4,5,6,7,8,9,10);
  833.    randomise(availableCustomers);
  834.    i = 1;
  835.    while(i <= 5)
  836.    {
  837.       bg["table" + i].state = "cleanBoth";
  838.       bg["table" + i].food1._visible = false;
  839.       bg["table" + i].food2._visible = false;
  840.       bg["table" + i].drink1._visible = false;
  841.       bg["table" + i].drink2._visible = false;
  842.       bg["table" + i].f1Done = false;
  843.       bg["table" + i].f2Done = false;
  844.       bg["table" + i].d1Done = false;
  845.       bg["table" + i].d2Done = false;
  846.       bg["table" + i].chair1 = "";
  847.       bg["table" + i].chair2 = "";
  848.       bg["table" + i].firstChair = "";
  849.       bg["table" + i].secondChair = "";
  850.       _root["tIcon" + i].gotoAndStop("init");
  851.       _root["tIcon" + i].num.gotoAndStop(i);
  852.       i++;
  853.    }
  854.    overlay._x = -100;
  855.    popup.gotoAndPlay("plate");
  856.    bg.heroine.gotoAndStop("initLeft");
  857.    bg.heroine._x = bg.initPos._x;
  858.    bg.heroine.moving = false;
  859.    bg.heroine.moveDirection = "left";
  860.    bg.heroine.destination = "";
  861.    bg.heroine.food1 = "";
  862.    bg.heroine.food2 = "";
  863.    bg.heroine.drink1 = "";
  864.    bg.heroine.drink2 = "";
  865.    bg.heroine.carryFood1 = "";
  866.    bg.heroine.carryFood2 = "";
  867.    bg.heroine.carryDrink1 = "";
  868.    bg.heroine.carryDrink2 = "";
  869.    bg.heroine.atTable = "";
  870.    bg.heroine.active = false;
  871.    bg.heroine.cateringChair = false;
  872.    bg.worker.gotoAndStop("init");
  873.    bg.worker.active = false;
  874.    bg.worker.bin.gotoAndStop("init");
  875.    bg.coffeeCups.gotoAndStop("init");
  876.    bg.coffeeCups.active = false;
  877.    activity.gotoAndStop("kitchen");
  878.    activity.active = false;
  879.    bg.dishes.gotoAndStop("init");
  880.    i = 1;
  881.    while(i <= maxWastePlates)
  882.    {
  883.       bg.dishes["plate" + i]._visible = false;
  884.       i++;
  885.    }
  886.    bg.dishes.active = false;
  887.    bg.drinkMaker.active = false;
  888.    bg.kitchen.gotoAndStop("init");
  889.    bg.kitchen.order = "";
  890.    bg.kitchen.food._visible = false;
  891.    bg.kitchen.delivered = false;
  892.    bg.kitchen.active = false;
  893.    kitchenTimer = 0;
  894.    status_Mc.gotoAndStop("blank");
  895.    statusArrow.gotoAndStop("idle");
  896.    life = 3;
  897.    life1._visible = true;
  898.    life2._visible = true;
  899.    life3._visible = true;
  900.    i = 1;
  901.    while(i <= 10)
  902.    {
  903.       bg["customer" + i]._x = customerEntry;
  904.       i++;
  905.    }
  906.    releaseCustomer();
  907.    centreOnX("kitchen");
  908.    Paused = false;
  909. }
  910. function setDirection()
  911. {
  912.    if(bg.heroine._x > bg[bg.heroine.destination]._x)
  913.    {
  914.       if(bg.heroine.moveDirection != "left")
  915.       {
  916.          bg.heroine.moveDirection = "";
  917.          bg.heroine.gotoAndPlay("turnLeft");
  918.       }
  919.       else
  920.       {
  921.          bg.heroine.moveDirection = "left";
  922.          bg.heroine.gotoAndPlay("walkLeft");
  923.       }
  924.    }
  925.    else if(bg.heroine._x < bg[bg.heroine.destination]._x)
  926.    {
  927.       if(bg.heroine.moveDirection != "right")
  928.       {
  929.          bg.heroine.moveDirection = "";
  930.          bg.heroine.gotoAndPlay("turnRight");
  931.       }
  932.       else
  933.       {
  934.          bg.heroine.moveDirection = "right";
  935.          bg.heroine.gotoAndPlay("walkRight");
  936.       }
  937.    }
  938. }
  939. function convertToLocal(myPoint)
  940. {
  941.    bg.localToGlobal(myPoint);
  942.    return myPoint.x;
  943. }
  944. function releaseCustomer()
  945. {
  946.    releaseCount = customerReleaseDelay;
  947.    var _loc3_ = new Array();
  948.    for(i in occuppiedChairs)
  949.    {
  950.       if(occuppiedChairs[i] == 0 && customerChairArray[i] == "")
  951.       {
  952.          _loc3_.push(i);
  953.       }
  954.    }
  955.    if(_loc3_.length > 0)
  956.    {
  957.       var _loc2_ = Number(_loc3_[random(_loc3_.length)]);
  958.       customerChairArray[_loc2_] = availableCustomers.pop();
  959.       bg["customer" + customerChairArray[_loc2_]].gotoAndPlay("walkRight");
  960.       bg["customer" + customerChairArray[_loc2_]].swapDepths(_root.bg.getNextHighestDepth());
  961.       bg.heroine.swapDepths(_root.bg.getNextHighestDepth());
  962.       bg["customer" + customerChairArray[_loc2_]]._x = customerEntry;
  963.       bg["customer" + customerChairArray[_loc2_]].moving = true;
  964.       bg["customer" + customerChairArray[_loc2_]].moveDirection = "right";
  965.       bg["customer" + customerChairArray[_loc2_]].destination = "chair" + (1 + _loc2_);
  966.       bg["customer" + customerChairArray[_loc2_]].chair = 1 + _loc2_;
  967.       occuppiedChairs[_loc2_] = 3 * customerWait;
  968.       bg["customer" + customerChairArray[_loc2_]].chairIndex = _loc2_;
  969.       bg["customer" + customerChairArray[_loc2_]].gotFood = false;
  970.       bg["customer" + customerChairArray[_loc2_]].gotDrink = false;
  971.       bg["customer" + customerChairArray[_loc2_]].eating = false;
  972.       bg["customer" + customerChairArray[_loc2_]].state = "";
  973.       bg["customer" + customerChairArray[_loc2_]].chairPosition = "";
  974.       switch(random(4))
  975.       {
  976.          case 0:
  977.             bg["customer" + customerChairArray[_loc2_]].food = "pizza";
  978.             break;
  979.          case 1:
  980.             bg["customer" + customerChairArray[_loc2_]].food = "hamburger";
  981.             break;
  982.          case 2:
  983.             bg["customer" + customerChairArray[_loc2_]].food = "hotdog";
  984.             break;
  985.          case 3:
  986.             bg["customer" + customerChairArray[_loc2_]].food = "fish";
  987.       }
  988.       switch(random(4))
  989.       {
  990.          case 0:
  991.             bg["customer" + customerChairArray[_loc2_]].drink = "cola";
  992.             break;
  993.          case 1:
  994.             bg["customer" + customerChairArray[_loc2_]].drink = "lime";
  995.             break;
  996.          case 2:
  997.             bg["customer" + customerChairArray[_loc2_]].drink = "orange";
  998.             break;
  999.          case 3:
  1000.             bg["customer" + customerChairArray[_loc2_]].drink = "coffee";
  1001.       }
  1002.    }
  1003. }
  1004. function updateTable(which, index)
  1005. {
  1006.    var _loc1_ = int((which - 1) / 2) + 1;
  1007.    switch(bg["customer" + customerChairArray[index]].chairIndex % 2)
  1008.    {
  1009.       case 0:
  1010.          if(bg["customer" + customerChairArray[index]].gotFood)
  1011.          {
  1012.             bg["table" + _loc1_].food1.gotoAndStop("plate");
  1013.          }
  1014.          if(bg["customer" + customerChairArray[index]].gotDrink)
  1015.          {
  1016.             bg["table" + _loc1_].drink1._visible = true;
  1017.             bg["table" + _loc1_].drink1.gotoAndStop(bg["table" + _loc1_].drink1._currentframe + 4);
  1018.          }
  1019.          bg["table" + _loc1_].state = "unclean1";
  1020.          break;
  1021.       case 1:
  1022.          if(bg["customer" + customerChairArray[index]].gotFood)
  1023.          {
  1024.             bg["table" + _loc1_].food2.gotoAndStop("plate");
  1025.          }
  1026.          if(bg["customer" + customerChairArray[index]].gotDrink)
  1027.          {
  1028.             bg["table" + _loc1_].drink2._visible = true;
  1029.             bg["table" + _loc1_].drink2.gotoAndStop(bg["table" + _loc1_].drink2._currentframe + 4);
  1030.          }
  1031.          bg["table" + _loc1_].state = "unclean2";
  1032.    }
  1033. }
  1034. function updateChair(which, index)
  1035. {
  1036.    var _loc5_ = (which - 1) % 2;
  1037.    var _loc2_ = int((which - 1) / 2) + 1;
  1038.    if(bg["table" + _loc2_].firstChair == "")
  1039.    {
  1040.       bg["table" + _loc2_].firstChair = bg["customer" + customerChairArray[index]];
  1041.       bg["customer" + customerChairArray[index]].chairPosition = "first";
  1042.       bg["table" + _loc2_].f1Done = false;
  1043.       bg["table" + _loc2_].d1Done = false;
  1044.       if(which % 2 == 0)
  1045.       {
  1046.          bg["table" + _loc2_].chair1 = "2";
  1047.       }
  1048.       else
  1049.       {
  1050.          bg["table" + _loc2_].chair1 = "1";
  1051.       }
  1052.       if(bg["table" + _loc2_].secondChair == "")
  1053.       {
  1054.          _root["tIcon" + _loc2_].gotoAndStop("wait");
  1055.          _root["tIcon" + _loc2_].table.gotoAndStop(_loc2_);
  1056.       }
  1057.       else if(bg["table" + _loc2_].secondChair.state != "order")
  1058.       {
  1059.          _root["tIcon" + _loc2_].icon1._visible = true;
  1060.          _root["tIcon" + _loc2_].dIcon1._visible = false;
  1061.          _root["tIcon" + _loc2_].fIcon1._visible = false;
  1062.          _root["tIcon" + _loc2_].drink1._visible = false;
  1063.          _root["tIcon" + _loc2_].food1._visible = false;
  1064.       }
  1065.    }
  1066.    else
  1067.    {
  1068.       bg["table" + _loc2_].secondChair = bg["customer" + customerChairArray[index]];
  1069.       bg["customer" + customerChairArray[index]].chairPosition = "second";
  1070.       bg["table" + _loc2_].f2Done = false;
  1071.       bg["table" + _loc2_].d2Done = false;
  1072.       if(which % 2 == 0)
  1073.       {
  1074.          bg["table" + _loc2_].chair2 = "2";
  1075.       }
  1076.       else
  1077.       {
  1078.          bg["table" + _loc2_].chair2 = "1";
  1079.       }
  1080.       _root["tIcon" + _loc2_].icon2._visible = true;
  1081.       _root["tIcon" + _loc2_].dIcon2._visible = false;
  1082.       _root["tIcon" + _loc2_].fIcon2._visible = false;
  1083.       _root["tIcon" + _loc2_].drink2._visible = false;
  1084.       _root["tIcon" + _loc2_].food2._visible = false;
  1085.    }
  1086. }
  1087. function randomise(passedArray)
  1088. {
  1089.    var _loc4_ = passedArray.length;
  1090.    var _loc3_ = new Array();
  1091.    i = 0;
  1092.    while(i < _loc4_)
  1093.    {
  1094.       var _loc2_ = random(passedArray.length);
  1095.       _loc3_.push(passedArray[_loc2_]);
  1096.       passedArray.splice(_loc2_,1);
  1097.       i++;
  1098.    }
  1099.    passedArray.splice(0);
  1100.    i = 0;
  1101.    while(i < _loc3_.length)
  1102.    {
  1103.       passedArray[i] = _loc3_[i];
  1104.       i++;
  1105.    }
  1106. }
  1107. var stageCentre = 380;
  1108. var bgRightExtreme = -334.35;
  1109. var bgLeftExtreme = 1066.95;
  1110. var life;
  1111. var Paused = true;
  1112. var score;
  1113. var heroineSpeed = 16;
  1114. var kitchenTimer = 0;
  1115. var customerEntry = bg.customerEntry_mc._x;
  1116. var customerReleaseDelay = 600;
  1117. var minCustomerReleaseDelay = 200;
  1118. var speedUpdate = 500;
  1119. var speedUpdateRate = 25;
  1120. var releaseCount = 0;
  1121. var customerSpeed = 9;
  1122. var customerWait = 700;
  1123. var maxWastePlates = 6;
  1124. var currentWastePlates = 0;
  1125. var currentWasteGlasses = 0;
  1126. var maxWasteGlasses = 10;
  1127. var maxCoffeeGlasses = 16;
  1128. var binFrame = 1;
  1129. var maxDrinks = 10;
  1130. var occuppiedChairs = new Array(0,0,0,0,0,0,0,0,0,0);
  1131. var customerChairArray = new Array("","","","","","","","","","");
  1132. var availableCustomers = new Array(1,2,3,4,5,6,7,8,9,10);
  1133. _root.onEnterFrame = function()
  1134. {
  1135.    if(!Paused)
  1136.    {
  1137.       if(_ymouse < 350)
  1138.       {
  1139.          if(_xmouse < 253.33333333333334 && bg._x < bgLeftExtreme - (253.33333333333334 - _xmouse) / 10)
  1140.          {
  1141.             bg._x += (253.33333333333334 - _xmouse) / 10;
  1142.          }
  1143.          else if(_xmouse > 506.6666666666667 && bg._x > bgRightExtreme + (_xmouse - 506.6666666666667) / 10)
  1144.          {
  1145.             bg._x -= (_xmouse - 506.6666666666667) / 10;
  1146.          }
  1147.          else if(_xmouse < 253.33333333333334)
  1148.          {
  1149.             bg._x = bgLeftExtreme;
  1150.          }
  1151.          else if(_xmouse > 506.6666666666667)
  1152.          {
  1153.             bg._x = bgRightExtreme;
  1154.          }
  1155.       }
  1156.       if(bg.heroine.moving)
  1157.       {
  1158.          if(bg.heroine.destination != "")
  1159.          {
  1160.             if(Math.abs(bg[bg.heroine.destination]._x - bg.heroine._x) > 10)
  1161.             {
  1162.                switch(bg.heroine.destination)
  1163.                {
  1164.                   case "table1":
  1165.                      status_Mc.gotoAndStop("table");
  1166.                      status_Mc.clip.gotoAndStop(1);
  1167.                      break;
  1168.                   case "table2":
  1169.                      status_Mc.gotoAndStop("table");
  1170.                      status_Mc.clip.gotoAndStop(2);
  1171.                      break;
  1172.                   case "table3":
  1173.                      status_Mc.gotoAndStop("table");
  1174.                      status_Mc.clip.gotoAndStop(3);
  1175.                      break;
  1176.                   case "table4":
  1177.                      status_Mc.gotoAndStop("table");
  1178.                      status_Mc.clip.gotoAndStop(4);
  1179.                      break;
  1180.                   case "table5":
  1181.                      status_Mc.gotoAndStop("table");
  1182.                      status_Mc.clip.gotoAndStop(5);
  1183.                      break;
  1184.                   case "coffeePos":
  1185.                      status_Mc.gotoAndStop("coffee");
  1186.                      break;
  1187.                   case "drinkPos":
  1188.                      status_Mc.gotoAndStop("drinks");
  1189.                      break;
  1190.                   case "kitchen":
  1191.                      status_Mc.gotoAndStop("kitchen");
  1192.                      break;
  1193.                   case "dishPos":
  1194.                      status_Mc.gotoAndStop("wash");
  1195.                      break;
  1196.                   case "worker":
  1197.                      status_Mc.gotoAndStop("worker");
  1198.                      break;
  1199.                   case "recycle":
  1200.                      status_Mc.gotoAndStop("recycle");
  1201.                }
  1202.                if(bg.heroine.moveDirection == "right")
  1203.                {
  1204.                   statusArrow.gotoAndStop("right");
  1205.                   bg.heroine._x += heroineSpeed;
  1206.                }
  1207.                else if(bg.heroine.moveDirection == "left")
  1208.                {
  1209.                   statusArrow.gotoAndStop("left");
  1210.                   bg.heroine._x -= heroineSpeed;
  1211.                }
  1212.             }
  1213.             else
  1214.             {
  1215.                statusArrow.gotoAndStop("idle");
  1216.                status_Mc.gotoAndStop("blank");
  1217.                bg.heroine.active = true;
  1218.                bg.heroine._x = bg[bg.heroine.destination]._x;
  1219.                bg.heroine.moving = false;
  1220.                switch(bg.heroine.destination)
  1221.                {
  1222.                   case "table1":
  1223.                      handleTable(1);
  1224.                      break;
  1225.                   case "table2":
  1226.                      handleTable(2);
  1227.                      break;
  1228.                   case "table3":
  1229.                      handleTable(3);
  1230.                      break;
  1231.                   case "table4":
  1232.                      handleTable(4);
  1233.                      break;
  1234.                   case "table5":
  1235.                      handleTable(5);
  1236.                      break;
  1237.                   case "coffeePos":
  1238.                      handleTurn();
  1239.                      break;
  1240.                   case "drinkPos":
  1241.                      handleTurn();
  1242.                      break;
  1243.                   case "kitchen":
  1244.                      handleTurn();
  1245.                      break;
  1246.                   case "dishPos":
  1247.                      handleDishes();
  1248.                      break;
  1249.                   case "worker":
  1250.                      handleTurn();
  1251.                      break;
  1252.                   case "recycle":
  1253.                      handleTurn();
  1254.                }
  1255.             }
  1256.          }
  1257.       }
  1258.       for(i in occuppiedChairs)
  1259.       {
  1260.          if(occuppiedChairs[i] != 0)
  1261.          {
  1262.             occuppiedChairs[i] -= 1;
  1263.             if(occuppiedChairs[i] == 0)
  1264.             {
  1265.                var _loc2_ = int((Number(bg["customer" + customerChairArray[i]].destination.substr(5)) - 1) / 2) + 1;
  1266.                if(bg["customer" + customerChairArray[i]].eating)
  1267.                {
  1268.                   updateTable(Number(bg["customer" + customerChairArray[i]].destination.substr(5)),i);
  1269.                   if(bg["customer" + customerChairArray[i]].chairPosition == "first")
  1270.                   {
  1271.                      bg["table" + _loc2_].firstChair = "";
  1272.                   }
  1273.                   else
  1274.                   {
  1275.                      bg["table" + _loc2_].secondChair = "";
  1276.                   }
  1277.                }
  1278.                else if(bg["customer" + customerChairArray[i]].chairPosition == "first")
  1279.                {
  1280.                   if(bg["table" + _loc2_].secondChair == "")
  1281.                   {
  1282.                      _root["tIcon" + _loc2_].gotoAndStop("init");
  1283.                      _root["tIcon" + _loc2_].num.gotoAndStop(_loc2_);
  1284.                   }
  1285.                   else
  1286.                   {
  1287.                      _root["tIcon" + _loc2_].fIcon1._visible = false;
  1288.                      _root["tIcon" + _loc2_].dIcon1._visible = false;
  1289.                      _root["tIcon" + _loc2_].food1._visible = false;
  1290.                      _root["tIcon" + _loc2_].drink1._visible = false;
  1291.                   }
  1292.                   bg["table" + _loc2_].firstChair = "";
  1293.                }
  1294.                else
  1295.                {
  1296.                   if(bg["table" + _loc2_].firstChair == "")
  1297.                   {
  1298.                      _root["tIcon" + _loc2_].gotoAndStop("init");
  1299.                      _root["tIcon" + _loc2_].num.gotoAndStop(_loc2_);
  1300.                   }
  1301.                   else
  1302.                   {
  1303.                      _root["tIcon" + _loc2_].fIcon2._visible = false;
  1304.                      _root["tIcon" + _loc2_].dIcon2._visible = false;
  1305.                      _root["tIcon" + _loc2_].food2._visible = false;
  1306.                      _root["tIcon" + _loc2_].drink2._visible = false;
  1307.                   }
  1308.                   bg["table" + _loc2_].secondChair = "";
  1309.                }
  1310.                switch(Number(bg["customer" + customerChairArray[i]].destination.substr(5)) % 2)
  1311.                {
  1312.                   case 1:
  1313.                      bg["customer" + customerChairArray[i]].gotoAndPlay("leaveRight");
  1314.                      break;
  1315.                   case 0:
  1316.                      bg["customer" + customerChairArray[i]].gotoAndPlay("leaveLeft");
  1317.                }
  1318.                bg["customer" + customerChairArray[i]].destination = "customerEntry_mc";
  1319.                bg["customer" + customerChairArray[i]].swapDepths(_root.bg.getNextHighestDepth());
  1320.                bg.heroine.swapDepths(_root.bg.getNextHighestDepth());
  1321.             }
  1322.          }
  1323.       }
  1324.       for(k in customerChairArray)
  1325.       {
  1326.          if(bg["customer" + customerChairArray[k]].moving)
  1327.          {
  1328.             if(Math.abs(bg[bg["customer" + customerChairArray[k]].destination]._x - bg["customer" + customerChairArray[k]]._x) > 10)
  1329.             {
  1330.                if(bg["customer" + customerChairArray[k]].moveDirection == "right")
  1331.                {
  1332.                   bg["customer" + customerChairArray[k]]._x += customerSpeed;
  1333.                }
  1334.                else if(bg["customer" + customerChairArray[k]].moveDirection == "left")
  1335.                {
  1336.                   bg["customer" + customerChairArray[k]]._x -= customerSpeed;
  1337.                }
  1338.             }
  1339.             else
  1340.             {
  1341.                bg["customer" + customerChairArray[k]].moving = false;
  1342.                if(bg["customer" + customerChairArray[k]].destination == "customerEntry_mc")
  1343.                {
  1344.                   if(!bg["customer" + customerChairArray[k]].gotFood || !bg["customer" + customerChairArray[k]].gotDrink)
  1345.                   {
  1346.                      life--;
  1347.                      if(life <= 0)
  1348.                      {
  1349.                         gotoAndStop("gameover");
  1350.                      }
  1351.                   }
  1352.                   if(bg["customer" + customerChairArray[k]].gotFood == true)
  1353.                   {
  1354.                      score += 50;
  1355.                      if(minCustomerReleaseDelay < customerReleaseDelay && score % speedUpdate == 0)
  1356.                      {
  1357.                         customerReleaseDelay -= speedUpdateRate;
  1358.                      }
  1359.                   }
  1360.                   if(bg["customer" + customerChairArray[k]].gotDrink == true)
  1361.                   {
  1362.                      score += 50;
  1363.                      if(minCustomerReleaseDelay < customerReleaseDelay && score % speedUpdate == 0)
  1364.                      {
  1365.                         customerReleaseDelay -= speedUpdateRate;
  1366.                      }
  1367.                   }
  1368.                   occuppiedChairs[bg["customer" + customerChairArray[k]].chairIndex] = 0;
  1369.                   availableCustomers.push(customerChairArray[k]);
  1370.                   randomise(availableCustomers);
  1371.                   customerChairArray[k] = "";
  1372.                }
  1373.                else
  1374.                {
  1375.                   bg["customer" + customerChairArray[k]]._x = bg[bg["customer" + customerChairArray[k]].destination]._x;
  1376.                   switch(Number(bg["customer" + customerChairArray[k]].destination.substr(5)) % 2)
  1377.                   {
  1378.                      case 1:
  1379.                         bg["customer" + customerChairArray[k]].gotoAndPlay("sitRight");
  1380.                         break;
  1381.                      case 0:
  1382.                         bg["customer" + customerChairArray[k]].gotoAndPlay("sitLeft");
  1383.                   }
  1384.                   occuppiedChairs[bg["customer" + customerChairArray[k]].chairIndex] = customerWait;
  1385.                   updateChair(Number(bg["customer" + customerChairArray[k]].destination.substr(5)),k);
  1386.                }
  1387.             }
  1388.          }
  1389.       }
  1390.       if(kitchenTimer > 0)
  1391.       {
  1392.          kitchenTimer--;
  1393.          if(kitchenTimer == 0)
  1394.          {
  1395.             activity.active = false;
  1396.             bg.kitchen.gotoAndPlay("delivery");
  1397.             bg.kitchen.foodReady = true;
  1398.          }
  1399.       }
  1400.       if(releaseCount > 0)
  1401.       {
  1402.          releaseCount--;
  1403.          if(releaseCount == 0)
  1404.          {
  1405.             releaseCustomer();
  1406.          }
  1407.       }
  1408.       if(life == 3)
  1409.       {
  1410.          life3._visible = true;
  1411.       }
  1412.       else if(life == 2)
  1413.       {
  1414.          life2._visible = true;
  1415.          life3._visible = false;
  1416.       }
  1417.       else if(life == 1)
  1418.       {
  1419.          life1._visible = true;
  1420.          life2._visible = false;
  1421.       }
  1422.       else
  1423.       {
  1424.          life3._visible = false;
  1425.          life2._visible = false;
  1426.          life1._visible = false;
  1427.       }
  1428.    }
  1429. };
  1430. initGame();
  1431. stop();
  1432.